package edu.haiu.training.ui;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class TableAdd1 {
	private String username;
	private String password;
	private String comfirmPassword;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;

	}

	public String getComfirmPassword() {
		return comfirmPassword;
	}

	public void setComfirmPassword(String comfirmPassword) {
		this.comfirmPassword = comfirmPassword;
	}

	private List<TableAdd> list = new ArrayList<TableAdd>();

	// public String execute(){
	// list.add(new TableAdd("Edit" +"/"+ "Delete", "a", "1/2/1999", "active"));
	// list.add(new TableAdd("Edit" +"/"+ "Delete", "b", "2/3/2000",
	// "inactive"));
	// list.add(new TableAdd("Edit" +"/"+ "Delete", "b", "4/2/2012", "active"));
	// return "success";
	// }
	/*
	 * public String save(){ System.out.println("Hello"); return "success"; }
	 */
	public String execute() {

		return "success";
	}

	public String execute1() {
		return "success";
	}

	public List<TableAdd> getList() {
		return list;
	}

	public void setList(List<TableAdd> list) {
		this.list = list;
	}

	public String execute2() {

		if (password.equals(comfirmPassword)) {
			System.out.println("Hello");
			FileOutputStream fop = null;
			File file;
			String content = username + password ;
	 
			try {
	 
				file = new File("D:/newfile.txt");
				fop = new FileOutputStream(file);
	 
				if (!file.exists()) {
					file.createNewFile();
				}
	 
				byte[] contentInBytes = content.getBytes();
	 
				fop.write(contentInBytes);
				fop.flush();
				fop.close();
	 
				System.out.println("Done");
	 
			} catch (IOException e) {
				e.printStackTrace();
			} finally {
				try {
					if (fop != null) {
						fop.close();
					}
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return "success";
		} else
			return "unsuccess";
	}
}
